package mail;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import user.User;

/**
 *
 * @author Thorsten Ludwig
 */
@Entity
public class Mail implements Serializable {

    @OneToOne(cascade= CascadeType.ALL)
    private User from;
    
    private String recipient;
    
    private String subject;
    
    private String msg;
    
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date mailDate;
    @Id
    @GeneratedValue
    private Long id;

    public Mail() {
    }
    
    public Mail (User from, String to, String subject, String msg) {
        this.from = from;
        this.recipient = to;
        this.subject = subject;
        this.msg = msg;
        this.mailDate = new Date();
    }

    public Date getMailDate() {
        return this.mailDate;
    }

    public User getFrom() {
        return from;
    }

    public String getMsg() {
        return msg;
    }

    public String getSubject() {
        return subject;
    }

    public String getTo() {
        return recipient;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
}
